package com.huilian.iotbox.admin.wap.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.huilian.iotbox.admin.wap.dao.DisplayRackDao;
import com.huilian.iotbox.admin.wap.service.DeviceService;
import com.huilian.iotbox.admin.wap.service.DisplayRackService;
import com.huilian.iotbox.data.common.RedisKey;
import com.huilian.iotbox.data.common.ServerResponse;
import com.huilian.iotbox.data.dto.DisplayRackDto;
import com.huilian.iotbox.data.po.DisplayRack;
import com.huilian.iotbox.data.po.DisplayRackItem;
import com.huilian.iotbox.data.vo.DeviceVo;
import com.huilian.iotbox.data.vo.DisplayRackVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.util.List;

@Service
public class DisplayRackServiceImpl implements DisplayRackService {

    @Autowired
    private DisplayRackDao displayRackDao;

    @Override
    public void insert(DisplayRack displayRack) {
        displayRackDao.insert(displayRack);
    }

    @Override
    public Integer update(DisplayRack displayRack) {
        return displayRackDao.update(displayRack);
    }

    @Override
    public void delete(Integer deviceId, Integer merchantStoreId) {
        displayRackDao.delete(deviceId, merchantStoreId);
    }

    @Override
    public Integer updateById(DisplayRack updateDisplayRack) {
        return displayRackDao.updateById(updateDisplayRack);
    }

    @Override
    public List<DisplayRackVo> findDisplayByDeviceIdAndHierarchy(DisplayRackDto displayRackDto) {
        return displayRackDao.findDisplayByDeviceIdAndHierarchy(displayRackDto);
    }

    @Override
    public PageInfo findDisplayByDeviceId(DisplayRackDto displayRackDto) {
        displayRackDto.setHierarchy(null);
        PageHelper.startPage(displayRackDto.getPageNum(), displayRackDto.getPageSize(), true);
        List<DisplayRackVo> list = displayRackDao.findDisplayByDeviceIdAndHierarchy(displayRackDto);
        return new PageInfo<>(list);
    }

    @Override
    public List<DisplayRackVo> getHierarchyByDeviceId(DisplayRackDto displayRackDto) {
        return displayRackDao.getHierarchyByDeviceId(displayRackDto);
    }

    @Override
    public DisplayRack findDisplayByDeviceId(Integer deviceId) {
        return displayRackDao.findDisplayByDeviceId(deviceId);
    }
}
